//
//  UITextField+Placeholder.m
//  BuDeJie15
//
//  Created by xiaomage on 16/6/19.
//  Copyright © 2016年 seemygo. All rights reserved.
//

#import "UITextField+Placeholder.h"

@implementation UITextField (Placeholder)
// runtime
// 设置占位文字颜色
- (void)setPlaceholderColor:(UIColor *)color
{
    // attributedPlaceholder
//    NSMutableDictionary *attr = [NSMutableDictionary dictionary];
//    attr[NSForegroundColorAttributeName] = color;
//    self.attributedPlaceholder = [[NSAttributedString alloc] initWithString:self.placeholder attributes:attr];
    
    // 设置占位文字颜色 => 猜测文本框占位文字是UILabel => 拿到这个label就好 => runtime(获取一个类中所有属性名) => 断点
    // 注意点:判断有没有文字,用长度
    if (self.placeholder.length == 0) {
        self.placeholder = @" ";
    }
    UILabel *placeholderLabel = [self valueForKey:@"placeholderLabel"];
    placeholderLabel.textColor = color;
    
}

- (UIColor *)placeholderColor
{
    return nil;
}

@end
